<template>
  <a-drawer :open="visible" title="配送司机详情" @close="onClose">
    <template #closeIcon>
      <close @on-close="onClose" />
    </template>
    <a-card size="small" title="基本信息">
      <a-descriptions size="small" :column="3">
        <a-descriptions-item label="编号">
          <CopyText :text="options.id">{{ options.id }}</CopyText>
        </a-descriptions-item>
        <a-descriptions-item label="姓名">{{ options.name }}</a-descriptions-item>
        <a-descriptions-item label="身份证号">{{ options.id_card }}</a-descriptions-item>
        <a-descriptions-item label="联系电话">{{ options.phone }}</a-descriptions-item>
        <a-descriptions-item label="入职时间">{{ options.create_time }}</a-descriptions-item>
        <a-descriptions-item label="在职状态">
          <span>{{ getDescByValue('JOD_STATUS_ENUM', options.job_status) }}</span>
        </a-descriptions-item>
        <a-descriptions-item label="住址">{{ options.address }}</a-descriptions-item>
      </a-descriptions>
    </a-card>
    <a-card class="smart-margin-top10" size="small" :tab-list="tabList" :active-tab-key="activeKey" @tabChange="(key) => (activeKey = key)">
      <template #customTab="{ tab }">
        <span class="ant-card-head-title" :style="compactModeClass">
          {{ tab }}
        </span>
      </template>
      <template v-if="activeKey === 'employee'">
        <div style="margin: 20px 0">
          <a-descriptions size="small" :column="3">
            <a-descriptions-item label="账号">{{ options.phone }}</a-descriptions-item>
            <a-descriptions-item label="登录次数">{{ options.login_num }}</a-descriptions-item>
          </a-descriptions>
        </div>
      </template>
    </a-card>
    <template #footer>
      <a-button @click="onClose">取消</a-button>
    </template>
  </a-drawer>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import { useEnums } from '@/hooks/plugins/useEnums'
import { inject } from 'vue'
const compactModeClass = inject('compactModeClass')
const { getDescByValue } = useEnums()

defineExpose({
  showDrawer
})
const emit = defineEmits(['refresh'])

// --------------------- Drawer 显示与隐藏 ---------------------
// 是否展示
const visible = ref(false)
// 详情
const options = ref({})
// 详情tab
const activeKey = ref('employee')
const tabList = [
  {
    key: 'employee',
    tab: '账号信息'
  }
]

function showDrawer(item) {
  options.value = item
  visible.value = true
}

const onClose = () => {
  visible.value = false
}
</script>
